/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo.tabla;

import java.awt.Image;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.table.AbstractTableModel;
import modelo.Stockitem;

/**
 *
 * @author MarioPT
 */
public class StockTableModel extends AbstractTableModel {

    private ArrayList<Stockitem> datos;
    private Vector<String> vColumnNames = new Vector();

    public StockTableModel(ArrayList<Stockitem> modelosdata) {
        this.datos = modelosdata;
        this.vColumnNames.add("ID Articulo");
        this.vColumnNames.add("Almacen");
        this.vColumnNames.add("Descripcion");
        this.vColumnNames.add("Precio");
        this.vColumnNames.add("Cantidad");
        this.vColumnNames.add("Pedidos");
    }

    public int getColumnCount() {
        return vColumnNames.size();
    }

    public int getRowCount() {
        return datos.size();
    }

    public String getColumnName(int col) {
        return vColumnNames.get(col);
    }

    
    public Object getValueAt(int row, int col) {
         Stockitem p = datos.get(row);
        Object retorno=null;
        if (col==0) {
            retorno = p.getArticulo().getIdArticulo();
        } else if (col==1) {
            retorno = p.getArticulo().getIdAlmacen();
        } else if (col==2) {
            retorno  = p.getArticulo().getDescripcion();
        } else if (col==3) {
            retorno = p.getArticulo().getPrecio();
        } else if (col==4) {
            retorno = p.getArticulo().getCantidad();
        } else if (col==5) {
            retorno = p.getPedidos();            
        }
        return retorno;
}
    
        public Class<?> getColumnClass(int column) {
        switch(column) {
            case 0: return Integer.class;
            case 1: return Integer.class;
            case 2: return String.class;
            case 3: return Integer.class;
            case 4: return Integer.class;
            case 5: return Integer.class;
            default: return Object.class;
        }
    }
        
        
   /* public boolean isCellEditable(int row, int col) {
        boolean retorno = true;
        if (col==6) {
            retorno = false;
        }
        return retorno;
    }*/
}